<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue局部组件的使用</title>
    <!-- 导入vue库依赖 -->
    <script src="./js/vue.js"></script>
    <script src="./js/vue-router.js"></script>
</head>

<body>
    <div id="app">
        <hello-world></hello-world>
        <hello-tom></hello-tom>
        <hello-jerry></hello-jerry>
    </div>
    <script>

        // 局部组件的定义  局部组件只能在父组件中使用 不能在其他地方使用
        var HelloWorld = {
            data: function () {
                return {}
            },
            template: `<div>helloworld</div>`
        }

        var HelloTom = {
            data: function () {
                return {}
            },
            template: `<div>hellotom</div>`
        }

        var HelloJerry = {
            data: function () {
                return {}
            },
            template: `<div>hellojerry</div>`
        }

        var vm = new Vue({
            el: '#app',
            data: {
                msg: ''
            },
            methods: {
            },
            //  局部组件定义在父组件中使用
            components: {
                'hello-world': HelloWorld,
                'hello-tom': HelloTom,
                'hello-jerry': HelloJerry
            }
        })
    </script>
</body>

</html>